import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {JobDescription} from '../../types/resp/JobDescription';

@Component({
  selector: 'job-description-view',
  imports: [
    SharedModule
  ],
  templateUrl: './job-description-view.component.html',
  standalone: true
})
export class JobDescriptionViewComponent implements OnInit {
  jobDescriptionForm!: FormGroup;
  isVisible: boolean = false
  title: string = '招聘岗位详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.jobDescriptionForm = this.fb.group({
      enterpriseName: [''],
      jobTitle: [''],
      departmentName: [''],
      workLocation: [''],
      jobType: [undefined],
      salaryRange: [undefined],
      postingDate: [''],
      closingDate: [''],
      headCount: [0],
      status: [undefined],
      responsibilities: [''],
      requirement: [''],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(jobDescription: JobDescription) {
    this.isVisible = true
    this.jobDescriptionForm.patchValue(jobDescription);
    this.jobDescriptionForm.disable();
  }
}
